#include "define.h"
#include "Uart.h"
#include "stdio.h"
#include "stdlib.h"
#include "cirqueue.h"

typedef struct 
{
   uint16 Head;
	 uint16 Tail;
	 uint16 Lenght;
	 uint8 Ring_Buff[RINGBUFF_LEN];
}RingBuff_t;

RingBuff_t ringbuff;

void RingBuff_Init(void)
{

	ringbuff .Head=0;
	ringbuff .Lenght =0;
	ringbuff .Tail =0;
	
}


uint8 Write_RingBuff(uint8 data)
{
		if(ringbuff .Lenght >=RINGBUFF_LEN )
		{
			return FLASE ;
		}
		ringbuff .Ring_Buff [ringbuff.Tail]=data;
		ringbuff .Tail = (ringbuff.Tail+1)%RINGBUFF_LEN ;
		ringbuff .Lenght ++;
		return TRUE ;

}


uint8 Read_RingBuff(uint8 *rData)
{
		if(ringbuff.Lenght == 0)
		{
			 return FLASE ;
		}
		*rData = ringbuff.Ring_Buff[ringbuff.Head];
		ringbuff .Head = (ringbuff.Head+1)%RINGBUFF_LEN ;
		ringbuff .Lenght --;
		return TRUE;
}







